package com.zorn.platform.role.service.impl;

import java.util.List;
import java.util.Map;

import org.apache.commons.collections.MapUtils;
import org.springframework.stereotype.Service;

import com.zorn.core.provider.ServiceSupportProvider;
import com.zorn.platform.role.service.IRoleService;
import com.zorn.platform.role.dao.RoleDao;

@Service
public class RoleService extends ServiceSupportProvider implements IRoleService {

	/* Fields
	================================================== */
	private RoleDao roleDao;

	/* Methods
	================================================== */
	public List<Map<String, Object>> query(Map<String, Object> params) {
		List<Map<String, Object>> data = roleDao.query(params);

		return setQueryResult(isPaging() ? roleDao.count(params) : data.size(), data);
	}

	public int count(Map<String, Object> params) {
		return setCountResult(roleDao.count(params));
	}

	public String insert(Map<String, Object> params) {
		return setInsertResult(roleDao.insert(params), MapUtils.getString(params, "id"));
	}

	public int update(Map<String, Object> params) {
		return setUpdateResult(roleDao.update(params));
	}

	public int delete(Map<String, Object> params) {
		return setDeleteResult(roleDao.delete(params));
	}

	/* Getters & Setters
	================================================== */
	public void setRoleDao(RoleDao roleDao) {
		this.roleDao = roleDao;
	}

}